package com.antis.olsl.magic.rank.detail;

import android.text.TextUtils;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.antis.olsl.arouterlib.MagicRoutePath;
import com.antis.olsl.base.BaseActivity;
import com.antis.olsl.magic.databinding.ActivityCommodityDetailBinding;
import com.antis.olsl.magic.response.GetTopAnalysisDetailResp;

/**
 * 商品详情
 */
@Route(path = MagicRoutePath.ACTIVITY_COMMODITY_DETAIL)
public class CommodityDetailActivity extends BaseActivity<ActivityCommodityDetailBinding> {

    @Autowired
    GetTopAnalysisDetailResp.ContentBean bean;

    @Override
    protected ActivityCommodityDetailBinding getViewBinding() {
        return ActivityCommodityDetailBinding.inflate(getLayoutInflater(), baseBinding.getRoot(), true);
    }

    @Override
    protected void initViews() {
        ARouter.getInstance().inject(this);
    }

    @Override
    protected void initData() throws IllegalAccessException {
        if (null == bean) {
            finish();
        }

        if (!TextUtils.isEmpty(bean.productName)) {
            viewBinding.textCommodityName.setText(bean.productName);
        }

        if (!TextUtils.isEmpty(bean.productCode)) {
            String commodityCoding = "商品编码" + bean.productCode;
            viewBinding.textCommodityCoding.setText(commodityCoding);
        }

        if (!TextUtils.isEmpty(bean.attribute)) {
            viewBinding.textCommodityAttr.setText(bean.attribute);
        }

        if (!TextUtils.isEmpty(bean.rankQuantity)) {
            viewBinding.layoutCommodityRank.textNumberRank.setText(bean.rankQuantity);
        }

        if (!TextUtils.isEmpty(bean.rankSum)) {
            viewBinding.layoutCommodityRank.textAmountRank.setText(bean.rankSum);
        }

        if (!TextUtils.isEmpty(bean.rankGrossMargin)) {
            viewBinding.layoutCommodityRank.textProfitRank.setText(bean.rankGrossMargin);
        }

        if (!TextUtils.isEmpty(bean.saleGrossMarginRatio)) {
            viewBinding.layoutCommoditySales.textProfitMargin.setText(bean.saleGrossMarginRatio);
        }

        if (!TextUtils.isEmpty(bean.salePermeability)) {
            viewBinding.layoutCommoditySales.textPermeability.setText(bean.salePermeability);
        }

        if (!TextUtils.isEmpty(bean.saleTurnoverRatio)) {
            viewBinding.layoutCommoditySales.textTurnover.setText(bean.saleTurnoverRatio);
        }

        if (!TextUtils.isEmpty(bean.saleNumbProportion)) {
            viewBinding.layoutCommoditySales.textNumberProportion.setText(bean.saleNumbProportion);
        }

        if (!TextUtils.isEmpty(bean.saleNumb)) {
            viewBinding.layoutCommoditySales.textNumber.setText(bean.saleNumb);
        }

        if (!TextUtils.isEmpty(bean.saleSumProportion)) {
            viewBinding.layoutCommoditySales.textAmountProportion.setText(bean.saleSumProportion);
        }

        if (!TextUtils.isEmpty(bean.saleSum)) {
            viewBinding.layoutCommoditySales.textAmount.setText(bean.saleSum);
        }

        if (!TextUtils.isEmpty(bean.saleGrossMarginProportion)) {
            viewBinding.layoutCommoditySales.textProfitProportion.setText(bean.saleGrossMarginProportion);
        }

        if (!TextUtils.isEmpty(bean.saleGrossMargin)) {
            viewBinding.layoutCommoditySales.textProfit.setText(bean.saleGrossMargin);
        }

        if (!TextUtils.isEmpty(bean.saleInventoryCost)) {
            viewBinding.layoutCommoditySales.textPurchasePrice.setText(bean.saleInventoryCost);
        }

        if (!TextUtils.isEmpty(bean.saleInventoryTotalPrice)) {
            viewBinding.layoutCommoditySales.textRetailPrice.setText(bean.saleInventoryTotalPrice);
        }

        if (!TextUtils.isEmpty(bean.productCategory)) {
            viewBinding.layoutCommodityInfo.textCommodityCategory.setText(bean.productCategory);
        }

        if (!TextUtils.isEmpty(bean.productType)) {
            viewBinding.layoutCommodityInfo.textCommodityType.setText(bean.productType);
        }

        if (!TextUtils.isEmpty(bean.specification)) {
            viewBinding.layoutCommodityInfo.textCommoditySku.setText(bean.specification);
        }

        if (!TextUtils.isEmpty(bean.unit)) {
            viewBinding.layoutCommodityInfo.textCommodityUnit.setText(bean.unit);
        }

        if (!TextUtils.isEmpty(bean.inventoryNumb)) {
            viewBinding.layoutCommodityInfo.textCommodityNumber.setText(bean.inventoryNumb);
        }

        if (!TextUtils.isEmpty(bean.price)) {
            viewBinding.layoutCommodityInfo.textCommodityPrice.setText(bean.price);
        }

        if (!TextUtils.isEmpty(bean.priceProfitRatio)) {
            viewBinding.layoutCommodityInfo.textCommodityProfitMargin.setText(bean.priceProfitRatio);
        }
    }
}
